package webTest.sessionCookie.LastView;

import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by IFT8 on 2015/1/27.
 *
 */
public class CleanCookie extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Cookie cookie = new Cookie("lastView", "");
        cookie.setMaxAge(0);//以秒为单位，没有设置MaxAge就默认为会话级Cookie,0为删除
        response.addCookie(cookie);
        response.sendRedirect(request.getContextPath() + "Index");
    }
}
